<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>switch语句</title>
</head>

<body>
  <script>
    let money = 1000
    while (true) {
      let num = +prompt(`
    请选择你的操作:
    1.存钱
    2.取钱
    3.查看余额
    4.退出
    `)
      if (num === 4) {
        alert('退出成功!')
        break
      }
      switch (num) {
        case 1:
          // 存钱操作
          let addMoney = +prompt('请输入您的存钱数额:')
          money = addMoney + money
          alert('您的当前余额是:' + money)
          break;
        case 2:
          // 取钱操作
          let reduceMoney = +prompt('请输入您要取的数额:')
          money -= reduceMoney
          alert('您的当前余额是:' + money)
          break;
        case 3:
          // 查看余额
          alert('您的当前余额是:' + money)
          break;
        default:
          break;
      }
    }
  </script>
</body>

</html>